<template>
  <div class="home">
    <el-carousel height="750px">
      <el-carousel-item v-for="item in swipers" :key="item.id">
        <img :src="$baseUrl + item.url" style="width:100%;height:100%" />
      </el-carousel-item>
    </el-carousel>
    <div class="refuse-wrapper">
      <div class="refuse-content">
        <h3>垃圾分类</h3>
        <p>进行垃圾分类收集可以减少垃圾处理量和处理设备，降低处理成本，减少土地资源的消耗，具有社会、经济、生态等几方面的效益。</p>
        <el-row justify="center" align="center" :gutter="20" style="margin-top:20px">
          <el-col :span="6">
            <el-row class="bg">
              <img src="../assets/image/metal.png" alt />
              <span class="bg-text">各类金属回收</span>
            </el-row>
            <el-row>
              <img src="../assets/image/metalb.png" alt />
            </el-row>
          </el-col>
          <el-col :span="6">
            <el-row class="bg">
              <img src="../assets/image/electron.png" alt />
              <span class="bg-text">各类电池回收</span>
            </el-row>
            <el-row>
              <img src="../assets/image/electronb.png" alt />
            </el-row>
          </el-col>
          <el-col :span="6">
            <el-row class="bg">
              <img src="../assets/image/page.png" alt />
              <span class="bg-text">书本纸张回收</span>
            </el-row>
            <el-row>
              <img src="../assets/image/pageb.png" alt />
            </el-row>
          </el-col>
          <el-col :span="6">
            <el-row class="bg">
              <img src="../assets/image/engineer.png" alt />
              <span class="bg-text">各类机械回收</span>
            </el-row>
            <el-row>
              <img src="../assets/image/engineerb.png" alt />
            </el-row>
          </el-col>
        </el-row>
        <el-row style="margin:40px 0;">
          <el-col>
            <el-button round type="success">VIEW MORE</el-button>
          </el-col>
        </el-row>
      </div>
      <div class="refuse-wrapper2">
        <div class="refuse-content">
          <h3>新鲜资讯</h3>
          <p>人们大量地消耗资源，大规模生产，大量地消费，又大量地生产着垃圾。后果将不堪设想</p>
          <el-row justify="center" align="center" :gutter="20" style="margin-top:20px">
            <el-col :span="6" v-for="item in articles" :key="item.id">
              <el-row>
                <img :src="$baseUrl+item.image" alt @click="toDetail(item.id)" />
              </el-row>
              <el-row>
                <h3 class="title" @click="toDetail(item.id)">{{item.title}}</h3>
                <p class="desc">{{item.description}}</p>
              </el-row>
            </el-col>
          </el-row>
          <el-row style="margin:40px 0;">
            <el-col>
              <el-button round type="success">VIEW MORE</el-button>
            </el-col>
          </el-row>
        </div>
      </div>
      <div class="refuse-wrapper">
        <div class="refuse-content">
          <h3>垃圾分类的意义</h3>
          <p>垃圾分类回收说难不难，分而用之实为关键，因地制宜提供方便，自觉自治行为规范。</p>
          <el-row style="margin-top:48px;">
            <el-row :gutter="40" justify="center" align="center">
              <el-col :span="12">
                <el-row :gutter="20">
                  <el-col :span="16">
                    <h3>当前形势</h3>
                    <p>垃圾分类是对垃圾收集处置传统方式的改革，是对垃圾进行有效处置的一种科学管理方法。</p>
                  </el-col>
                  <el-col :span="8">
                    <img src="../assets/image/option.png" alt />
                  </el-col>
                </el-row>
              </el-col>
              <el-col :span="12">
                <el-row :gutter="20">
                  <el-col :span="16">
                    <h3>变废为宝</h3>
                    <p>消费环节产生的垃圾如果及时进行分类，回收再利用是解决垃圾问题的最好途径</p>
                  </el-col>
                  <el-col :span="8">
                    <img src="../assets/image/option2.png" alt />
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row :gutter="40" justify="center" align="center">
              <el-col :span="12">
                <el-row :gutter="20">
                  <el-col :span="16">
                    <h3>减少污染</h3>
                    <p>中国的垃圾处理多采用卫生填埋甚至简易填埋的方式，占用上万亩土地；并且虫蝇乱飞，污水四溢，臭气熏天，严重污染环境。</p>
                  </el-col>
                  <el-col :span="8">
                    <img src="../assets/image/option3.png" alt />
                  </el-col>
                </el-row>
              </el-col>
              <el-col :span="12">
                <el-row :gutter="20">
                  <el-col :span="16">
                    <h3>减少土地侵蚀</h3>
                    <p>生活垃圾中有些物质不易降解，使土地受到严重侵蚀。垃圾分类，去掉可以回收的、不易降解的物质，减少垃圾数量达60%以上。</p>
                  </el-col>
                  <el-col :span="8">
                    <img src="../assets/image/option4.png" alt />
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Index",

  data() {
    return {
      swipers: [],
      articles: []
    };
  },
  mounted() {
    this.getSwiper();
    this.getRandArticle();
  },

  methods: {
    toDetail(id) {
      this.$router.push({
        name: "art-detail",
        query: {
          id
        }
      });
    },
    async getSwiper() {
      const res = await this.$http.get("/users/swiper");
      this.swipers = res.data;
    },

    async getRandArticle() {
      const res = await this.$http.get(`/users/hotNews?limit=${4}`);
      this.articles = res.data.rows;
    }
  }
};
</script>
<style lang="less" scoped>
@import "../assets/style/index";
</style>